(function ($) {
    var attr = {
        tab_type : location.href.substr(location.href.indexOf('#')+1,location.href.length)
    };
	var docMain = {
		type1_button : $('.J-password-login'),
		type2_button : $('.J-code-login'),
		allContainer : $('.login-type-container'),
		type1_container : $('#J-password-container'),
		type2_container : $('#J-code-container'),
		wechat_login : $('#wechat-login'),
        error_container : $('.login-error-container'),
        redirect : $('#redirect')
	};
    switch (attr.tab_type){
        case 'password':
            showPasswordView();
            break;
        case 'code':
            showCodeView();
            break;
    }
    //显示密码登录模块
    function showPasswordView() {
        docMain.type1_button.siblings().removeClass('active');
        docMain.type1_button.addClass('active');
        docMain.error_container.hide();
        docMain.allContainer.hide();
        docMain.type1_container.show();
    }
    //显示验证码登录模块
    function showCodeView() {
        docMain.type2_button.siblings().removeClass('active');
        docMain.type2_button.addClass('active');
        docMain.error_container.hide();
        docMain.allContainer.hide();
        docMain.type2_container.show();
    }
    docMain.type1_button.click(showPasswordView);
	docMain.type2_button.click(showCodeView);
	//微信登录
	docMain.wechat_login.click(function () {
        var _redirect = docMain.redirect.val();
        var _url = encodeURIComponent('http://ytx.com/wechat/callback?redirect='+_redirect);
        var _appid = 'wx6dee0381d1c35685';
        var _wechat_url = 'https://open.weixin.qq.com/connect/qrconnect?appid='+_appid +
            '&redirect_uri='+_url +
            '&response_type=code&scope=snsapi_login#wechat_redirect';
		window.open(_wechat_url);
    });
})(jQuery);